document.addEventListener('scroll', function() {
    var sections = document.querySelectorAll('.floor');
    var links = document.querySelectorAll('.elevator ul li a');
  
    sections.forEach(function(section) {
      var rect = section.getBoundingClientRect();
      if (rect.top <= 0 && rect.bottom >= 0) {
        // 当前楼层在视口内
        links.forEach(function(link) {
          link.classList.remove('active'); // 移除所有链接的激活类
        });
        document.querySelector(`.elevator li a[href="#${section.id}"]`).classList.add('active'); // 添加当前楼层链接的激活类
      }
    });
  });
  document.querySelector('.elevator li a[href="#nev"]').addEventListener('click', function(e) {
    e.preventDefault();
    window.scrollTo({ top: 0, behavior: 'smooth' });
  });